package xyz.syyrjx.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import xyz.syyrjx.entity.ResultInfo;
import xyz.syyrjx.entity.User;
import xyz.syyrjx.utils.JWTUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Mr.Wan
 * @date 2022/10/11 - 20:51
 */
@RestController
public class MysqlUserController {

    @RequestMapping("/user/login")
    public ResultInfo<User> login(@RequestParam int id){
        User user = new User();
        List<String> authorities = new ArrayList<>();
        List<String> roles = new ArrayList<>();
        user.setUid(id);
        if (id == 1){
            user.setUsername("zs");
            //普通用户，订单查和删除
            authorities.add("order-get");
            authorities.add("order-delete");
            roles.add("normal");
        }else{
            user.setUsername("ls");
            //无权限的普通用户
            roles.add("normal");
        }
        user.setAuthorities(authorities);
        user.setRoles(roles);
        return ResultInfo.success(user);
    }
}
